<template>
  <el-select :value="value"  filterable  placeholder="请选择卡券" clearable :style="{ 'width': width }" @change="change">
    <el-option v-for="item in goodsList" :key="item.id" :label="item.couponName" :value="item.id" />
  </el-select>
</template>

<script>
/**
 * 业务组件 -
 */
export default {
  name: 'cpls',
  props: {
    /** 数据源 */
    value: {
      type: String,
      default: ''
    },
    /** 宽度 */
    width: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      api: this.$u.api.PluginsCouponmallCoupon,
      // 分组
      goodsList: []
    }
  },
  created() {
    // 初始化数据
    this.initData()
  },
  watch: {
    themeId(newVal, oldVal) {
      if (newVal) {
        this.value = ''
        this.initData()
      }
    }
  },
  methods: {
    // 初始化数据


    initData() {
      this.api.datalist().then(res => {
        this.goodsList = res.data
      })
    },
    change(e) {
      this.$emit('input', e)
      this.$emit('change', e)
    }
  }
}
</script>

<style lang="scss" scoped>
::v-deep{
  .el-input{
    width: 100% !important;
  }
}
</style>
